package com.esri.core.internal.util;

import com.esri.core.geometry.Envelope;
import com.esri.core.geometry.SpatialReference;
import com.github.mikephil.charting.utils.Utils;

/* loaded from: classes.dex */
public class j {
    public static SpatialReference a = SpatialReference.create(SpatialReference.WKID_WGS84);
    public static double b = 180.0d;
    public static double c = 2.003750834E7d;

    public static boolean a(double d, double d2, SpatialReference spatialReference) {
        Envelope pannableExtent;
        if (spatialReference == null || (pannableExtent = spatialReference.getPannableExtent()) == null) {
            return false;
        }
        return d < pannableExtent.getXMin() || d2 > pannableExtent.getXMax();
    }

    public static void a(Envelope envelope, double d, double d2, SpatialReference spatialReference) {
        if (a(spatialReference) == Utils.DOUBLE_EPSILON) {
            return;
        }
        double d3 = d2 * 2.0d;
        double centerX = envelope.getCenterX();
        double centerY = envelope.getCenterY();
        if (centerX > d2) {
            centerX -= Math.ceil(Math.abs(centerX - d2) / d3) * d3;
        } else if (centerX < d) {
            centerX += Math.ceil(Math.abs(centerX - d) / d3) * d3;
        }
        double width = envelope.getWidth() / 2.0d;
        double height = envelope.getHeight() / 2.0d;
        envelope.setCoords(centerX - width, centerY - height, centerX + width, centerY + height);
    }

    static double a(SpatialReference spatialReference) {
        double d;
        if (spatialReference.isAnyWebMercator()) {
            d = c;
        } else if (!spatialReference.isWGS84()) {
            return spatialReference.getPannableExtent() != null ? spatialReference.getPannableExtent().getWidth() : Utils.DOUBLE_EPSILON;
        } else {
            d = b;
        }
        return d * 2.0d;
    }
}
